/**
 * 表格扩展按钮click事件
 */
import afterEvent from './afterEvent';
import {headSumHandle} from './commonEvent';
const tableInnerBtnAction = window.presetVar.tableInnerBtnAction;
const body1 = window.presetVar.body.body1;
const statusVar = window.presetVar.status;

function tableExtendButtonClick() {
    return {
        [body1 + tableInnerBtnAction.Edit] : {
            afterClick: (record, index) => {
                // 切换展开/收起按钮 2207 下方代码已经无效
                if (record.expandRowStatus) { // 收起
                    let elem = document.querySelector(`.u-table-fixed-right tr[data-row-key='${record.rowid}'] a.row-btn-${body1}_Edit`);
                    elem.innerHTML = '收起';
                } else { // 展开
                    let elem = document.querySelector(`.u-table-fixed-right tr[data-row-key='${record.rowid}'] a.row-btn-${body1}_Edit`);
                    elem.innerHTML = '展开';
                }
            }
        },
        [body1 +  tableInnerBtnAction.Delete ] : {
            afterClick: (record, index) => {
                headSumHandle.call(this,this.props);
            }
        },
        [body1 +  tableInnerBtnAction.Copy]:{
            afterClick: (record, index) => {
                //  let changedrows =  this.props.cardTable.getRowsByIndexs(body1, 0);
                //  let value = this.props.cardTable.getValByKeyAndIndex(body1, 0,'amount');
                //  let prop = this.props;
                //  afterEvent.call(this,prop,body1,'amount',value , changedrows);
                headSumHandle.call(this,this.props);

       
            }
        },
        [body1 +  tableInnerBtnAction.Insert]:{
            afterClick: (record, index) => {
                let bbhlFlag = this.props.form.getFormItemsDisabled(window.presetVar.head.head1,'org_currinfo');
                this.props.cardTable.setEditableByIndex(body1, index+1, ['org_currinfo'], !bbhlFlag)
            }
        },
    }
}

export default tableExtendButtonClick;